package com.abei.gas.controller;

import com.abei.gas.entity.Card;
import com.abei.gas.service.Impl.CardServiceImpl;
import com.abei.gas.vo.DataVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/card")
@Api(tags = "IC卡管理相关接口")
public class CardController {
    @Autowired
    private CardServiceImpl cardService;

    @GetMapping("/findAll")
    public DataVo<Card> findAll(Integer page,Integer limit)
    {
        return cardService.findAll(page,limit);
    }

    @RequestMapping("/deleteById")
    public void deleteById(HttpServletRequest request){
        String id = request.getParameter("id");
        cardService.deleteById(id);
    }
    /*
    * 添加
    */
    @PostMapping("/insert")
    public void insert(@RequestBody Card card){
        cardService.Insert(card);
    }

    @RequestMapping("/updateById")
    public void updateById(@RequestBody Card card){
        String number=card.getId();
        cardService.Update(number,card);
    }

    //搜索
    @GetMapping("/selectById")
    public DataVo<Card> selectById(HttpServletRequest request) {
        String id = request.getParameter("id");
        return cardService.findById(id);
    }
    /*
    * 批量删除
    * */
    @RequestMapping("/deleteBatchIds")
    public void DDeletebatchIds(HttpServletRequest request){
        String ids=request.getParameter("ids");
        cardService.DeleteBatchIds(ids);
    }
}
